package com.zdkj.subway.support.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zdkj.subway.support.dto.out.StationDetailDTO;
import com.zdkj.subway.support.entity.SwParamLine;
import com.zdkj.subway.support.entity.SwParamStation;
import com.zdkj.subway.support.mapper.SwParamStationMapper;
import com.zdkj.subway.support.service.SwParamStationService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 车站设置表
 *
 * @author cui_com
 * @date 2020-01-08 17:13:42
 */
@Service
@AllArgsConstructor
public class SwParamStationServiceImpl extends ServiceImpl<SwParamStationMapper, SwParamStation> implements SwParamStationService {
    private SwParamStationMapper swParamStationMapper;

    @Override
    public IPage<StationDetailDTO> queryStationDetailByPage(IPage page, Wrapper queryWrapper) {
        return swParamStationMapper.queryStationDetailByPage(page, queryWrapper);
    }
    @Override
	public List<SwParamStation> getVlinelist(){
	    return swParamStationMapper.getVlinelist();
	}

    @Override
    public String getCodeByNameAndLineCode(String name, String lineCode) {
        SwParamStation swParamStation = this.getOne(Wrappers.<SwParamStation>query().lambda()
                .eq(SwParamStation::getName,name)
                .eq(SwParamStation::getLineCode,lineCode));
        if(ObjectUtil.isNotEmpty(swParamStation)){
            return swParamStation.getCode();
        }
        return "";
    }

}
